<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
[#include "/admin/include/head.htm"]
<script type="text/javascript">
   	$(function(){
		// 地区选择菜单
		$(".areaSelect").lSelect({
			url: "${base}/common/area.jhtml" // Json数据获取url
		});
	});
	
	function save(item, dialog){
		var flag = false;
        LG.submitForm($(mainform), function (data) {
            if (data.type && data.type == "SUCCESS") {
                $.ligerDialog.alert(data.content,function(){
                    dialog.hide();
                    parent.$.ligerDialog.close();
                    parent.$(".l-dialog,.l-window-mask").remove();
                });
                flag = true;
            } else {
                LG.showError(data.content);
            }
        },null,null,{async:false});
		return flag;
	}
</script>
</head>
<body style="padding:10px;">
	<div id="tabcontainer" style="margin:0; padding:0">
		<form action="${base}/admin/b2c/order/shipping.jhtml" method="post" class="validate" id="mainform">
			<input type="hidden" name="orderId" value="${(order.id)!''}"/>
			<table class="table">
				<tr>
					<th>订单编号：</th>
					<td>${(order.orderNo)!}</td>
				</tr>
				<tr>
					<th>物流单号：</th>
					<td>	
						<input type="text" name="logisticsNo" value="${(order.logisticsNo)!}" class="formText {required: true, maxlength: 50}" />
					</td>
				</tr>
				<tr>
					<th>配送方式：</th>				
					<td>
						[@u.select headerKey="" headerValue="请选择..." 
							listKey="id" listValue="name"
							headerButtom="false" list=deliveryMethodList 
							name="deliveryMethodId"  value="${(order.deliveryMethod.id)!}" class="{required: true}"/]
					</td>					
				</tr>
				<tr>
					<th>物流费用：</th>
					<td>	
						<input type="text" name="shipFee" value="${(order.shipFee)!0}" class="formText {required:true, maxlength: 20,number:true}"/>
						(订单运费: ${currency(order.shipFee, true)})
					</td>
				</tr>
				<tr>
					<th>发货点：</th>
					<td>		
   					  [@u.select headerKey="" headerValue="请选择..." 
   					  		listKey="id" listValue="name"
							headerButtom="false" list=deliveryCenterList
							name="deliveryCenterId" class="{required: true}"/]			
					</td>
				</tr>	
				<tr>
					<th>收货人：</th>
					<td>		
   					    <input type="text" name="receiver" value="${(order.consignee)!}" class="formText {required: true, maxlength: 20}" />
					</td>
				</tr>
				<tr>
					<th>电话/手机： </th>
					<td>		
   					    <input type="text" name="mobile" value="${(order.contact)!}" class="formText {required: true, maxlength: 20}" />				
					</td>
				</tr>
				<tr>
					<th>收货人地区：</th>
					<td>	
						<input type="hidden" name="areaId" treePath="${(area.path)!}" class="input1 areaSelect" value="${(area.id)!}" style="width:345px"/>
   					</td>
				</tr>					
				<tr>
					<th>收货人地址：</th>
					<td>	
						<input type="text" name="address" value="${(order.address)!}" 
							class="formText {required: true, maxlength: 250}" style="width:500px;"/> 
					</td>
				</tr>
				<tr>
					<th>邮编：</th>
					<td>	
						<input type="text" name="zipCode" value="${(order.zipCode)!}" class="formText {maxlength: 10}"/>
					</td>
				</tr>
			</table>
			
			<div class="table_title">
				<img src="${base}/resource/images/communication.gif">
				<span>发货项</span>
			</div>
			<table class="inputTable" style="width:100%;">
			<tbody>
				<tr class="title">
					<th>商品编号</th>
					<th>商品名称</th>
					<th>商品库存</th>
					<th>购买数量</th>
					<th>已发货数量</th>
					<th>发货数量</th>
				</tr>
			</tbody>
			[#assign canShippingCount = 0]
			[#list order.orderItems as orderItem]
				[#if !orderItem.refund?? || orderItem.refund.refundStatus = "refuse" || (orderItem.quantity - orderItem.refund.quantity) > 0]
				[#assign canShippingCount = canShippingCount + 1]
				[#assign refundCount = 0]
				[#if orderItem.refund?? && orderItem.refund.refundStatus != 'refuse']
					[#assign refundCount = orderItem.refund.quantity]
				[/#if]
				<tr>
					<td>
						<input type="hidden" name="orderItemIds" value="${orderItem.id}" />
						${orderItem.productCode}
					</td>
					<td>${orderItem.productName}</td>
					<td>${(orderItem.goods.stock)!'-'}</td>
					<td>${orderItem.quantity}</td>
					<td>${orderItem.shippedQuantity}</td>
					<td>
						<input type="text" name="quantitys" class="text shippingItemsQuantity"
							value="${orderItem.quantity-orderItem.shippedQuantity-refundCount}" min="1" max="${orderItem.quantity-orderItem.shippedQuantity-refundCount}"/>
					</td>
				</tr>
				[/#if]
			[/#list]
			[#if canShippingCount = 0]
                <tr>
                    <td colspan="6" style="text-align: center">
                        无可发货项
                    </td>
                </tr>
			[/#if]
			</table>

			<div class="table_title">
				<img src="${base}/resource/images/communication.gif">
				<span>已申请退款</span>
			</div>
			<table class="inputTable" style="width:100%;">
			<tbody>
				<tr class="title">
					<th>商品编号</th>
					<th>商品名称</th>
					<th>购买数量</th>
					<th>申请数量</th>
					<th>退换货</th>
					<th>状态</th>
				</tr>
			</tbody>
			[#assign refundedCount = 0]
			[#list order.orderItems as orderItem]
				[#if orderItem.refund?? && orderItem.refund.refundStatus != "refuse"]
					[#assign refundedCount = refundedCount + 1]
				<tr>
					<td>
						${orderItem.productCode}
					</td>
					<td>${orderItem.productName}</td>
					<td>${orderItem.quantity}</td>
					<td>
						${orderItem.refund.quantity}
					</td>
					<td>
						[#if orderItem.refund.isChange]
							换货
						[#else]
							退货
						[/#if]
					</td>
					<td>${message("RefundStatus."+orderItem.refund.refundStatus)}</td>
				</tr>
				[/#if]
			[/#list]
				[#if refundedCount = 0]
                    <tr>
                        <td colspan="6" style="text-align: center">
                            无退款记录
                        </td>
                    </tr>
				[/#if]
		</table>
		</form>
	</div>
</body>
</html>